/**
 * 
 */
package com.cipe.cmrs.controllers;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.cipe.cmrs.model.Donorawardtype;
import com.cipe.cmrs.service.DonorawardtypeService;

/**
 * @author Incepio
 *
 */
@Controller
public class DonorawardtypeController extends BaseController {

	/**
	 * 
	 */
	private static final long		serialVersionUID	= -3823562098119817733L;
	@Autowired
	private DonorawardtypeService	donorawardtypeService;

	@RequestMapping("/secure/saveDonorawardtype.do")
	public String SaveDonorawardtype(@ModelAttribute("donorawardtype") Donorawardtype donorawardtype, BindingResult result, Model model, HttpServletRequest request) {
		try {
			donorawardtype = donorawardtypeService.saveDonorawardtype(donorawardtype, getUserId(request));
			saveMessage(request, getText("editDonorawardtype.message.success"));
		} catch (Exception e) {
			logger.error(getText("error.transaction"), e);
			saveError(request, getText("error.transaction"));
		}
		model.addAttribute("donorawardtype", donorawardtype);
		return "editDonorawardtype";
	}

	@RequestMapping("/secure/showAddDonorawardtype.do")
	public String showAddDonorawardtype(Model model) {
		model.addAttribute("donorawardtype", new Donorawardtype());
		return "editDonorawardtype";
	}

	@RequestMapping("/secure/showDonorawardtypeList.do")
	public String showDonorawardtypeList(Model model) {
		model.addAttribute("donorawardtypes", donorawardtypeService.findAll());
		return "donorawardtypeList";
	}

	@RequestMapping("/secure/showEditDonorawardtype.do")
	public String showEditDonorawardtype(@RequestParam Integer id, Model model) {
		model.addAttribute("donorawardtype", donorawardtypeService.findById(id));
		return "editDonorawardtype";
	}
}
